#include<stdio.h>
#include<stdlib.h>
#define M 20
typedef struct
{
    int data[M];
    int rear;
    int front;
}queue;
void initqueue(queue*& q)
{
    q = (queue*)malloc(sizeof(queue));
    q->rear =q->front=-1;
}
void push(queue*& q, int& e)
{
    q->rear++;
    q->data[q->rear] = e;
}
void pop(queue*& q)
{
    q->front++;
}
void getfront(queue*& q, int& e)
{
    e = q->data[q->front+1];
}
void getrear(queue*& q, int& e)
{
    e = q->data[q->rear];
}
bool empty(queue*& q)
{
    return(q->rear == q->front);
}
